////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2010-2011 Kentaro Sekimoto  All rights reserved.
////////////////////////////////////////////////////////////////////////////

#ifndef ST7781_H_
#define ST7781_H_
#include "tinyhal.h"

struct ST7781_CONFIG {
	UINT16 Width;
	UINT16 Height;
	UINT16 BitsPerPixel;
	UINT16 fcol;
	UINT16 bcol;

	UINT16 TextSx;
	UINT16 TextSy;
};

extern ST7781_CONFIG g_ST7781_Config;

struct ST7781_Driver {
	UINT32 m_cx;
	UINT32 m_cy;

    static BOOL Initialize();
    static BOOL Uninitialize();
    static void PowerSave(BOOL On);
    static void Clear();
    static void BitBltEx(int x, int y, int width, int height, UINT32 data[]);
    static void BitBlt(int width, int height, int widthInWords, UINT32 data[], BOOL fUseDelta);
    static void WriteChar(unsigned char c, int row, int col);
    static void WriteChar16(unsigned short c, int row, int col);
    static void WriteFormattedChar(unsigned char c);
    static void WriteFormattedChar16(unsigned short s);
    static void BitBltEx565(int x, int y, int width, int height, UINT32 data[]);
private:
    static void WriteChar_Color(unsigned char c, UINT8 cx, UINT8 cy, UINT16 fgcol, UINT16 bgcol);
    static void WriteChar_Color16(unsigned short s, UINT8 cx, UINT8 cy, UINT16 fgcol, UINT16 bgcol);
};

extern ST7781_Driver g_ST7781_Driver;

#endif /* ST7781_H_ */
